home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Graphics Plus
/
Graphics Plus.iso
/
general
/
hdf
/
docs
/
hdfvset.lha
/
HDFVset.ch5
< prev
next >
Wrap
Text File
|
1994-01-10
|
11KB
|
424 lines
5.1 NCSA HDF Vset
Vdata Routine Descriptions 5.1
National Center for Supercomputing Applications
November 1990
5.1 NCSA HDF Vset
Vdata Routine Descriptions 5.1
National Center for Supercomputing Applications
November 1990
March 1990
Chapter 5 Vdata Routine Descriptions
Chapter Overview
VSattach
VSdetach
VSfdefine
VSfexist
VSgetclass
VSgetid
VSgetname
VSinquire
VSlone
VSread
VSseek
VSsetclass
VSsetfields
VSsetinterlace
VSsetname
VSwrite
Chapter Overview
This chapter describes the vdata routines in the C library in detail.
VSattach
(VDATA*) VSattach (f, vsid, access)
VGROUP *vg;
int vsid;
character *access;
Purpose: This access routine attaches to the vdata that has id vsid
within the opened HDF file (pointer f) and then returns a pointer to
that vdata.
Specifics: Access is either "r" (read) or "w" (write). Currently,
you may only write to a new vdata (by specifying vsid = -1). You
may not attach to any existing vdata for writing or appending new
data to it. The default interlace for a vdata attached with "w" access
is FULL_INTERLACE (Use VSsetinterlace to modify the
interlace).
If access is "r", vsid must be a valid id of an existing vdata as
returned from any of the search routines (Vgetnext or VSgetid).
Return value: If the attach is successful, a vdata pointer is
returned; otherwise, NULL is returned.
VSdetach
(void) VSdetach (vs)
VDATA *vs;
Purpose: This access routine detaches vs, the vdata that was
currently attached, terminating further access to that vdata.
Specifics: VSdetach updates the vdata information in the HDF file
if there are any changes. All memory used for that vdata is freed.
The pointer vs should not be used after that vdata is detached.
Return value: None.
VSfdefine
int VSfdefine (vs, field, fieldtype, order)
VDATA *vs;
char *field;
int fieldtype;
int order;
Purpose: This specify routine is used to define a new, or
unsupported field for which you have data to be written to that
vdata. (See the description of VSsetfields for more details about
such fields.)
Specifics: VSfdefine is used only on a vdata that has "w" access.
You specify a field by naming it as a character string in field, its
type in fieldtype, and its order in order.
The type may be one of the following:
LOCAL_FLOATTYPE for float type
LOCAL_INTTYPE for integer type
LOCAL_BYTETYPE for byte type
LOCAL LONGTYPE for long integer type
Note that an integer is stored as 2 bytes in the HDF file while a long
integer is stored as 4 bytes. A float is stored as 4 bytes.
The order of a field is the number of units of data type (float, int,
byte, or long) it comprises.
For instance, a field called VECTOR comprising 3 floats may be
defined by the call as follows:
VSfdefine(vs,VECTOR,LOCAL_FLOATTYPE,3);
Only one field may be defined per call.
NOTE: Defining a field using VSfdefine does not prepare the
storage format of the vdata. To do so, use VSsetfields.
Return value: Upon success, 1 is returned; otherwise, -1 is
returned.
VSfexist
int VSfexist (vs, fields)
VDATA *vs;
char *fields;
Purpose: This inquiry routine checks whether all the field(s)
specified in fields exists in the vdata vs.
Specifics: The fields argument is a string of comma-separated
fieldnames (e.g., PX, PY, PZ).
Return value: A value of 1 is returned if all field(s) exist;
otherwise -1 is returned
VSgetclass
(void) VSgetclass (vs,vsclass)
VDATA *vs;
char *vsclass;
Purpose: This inquiry routine returns in vsclass the class field
name (if any) of the vdata `.
Return value: None.
VSgetid
int VSgetid (f, vsid)
DF *f;
int vsid;
Purpose: This search routine searches through the HDF file and
returns the id of the next vdata after the vdata that has id vsid.
Specifics: To initiate a search, call this routine with a value of -1
for vsid. Doing so returns the id of the first vdata in the file.
Return value: Upon success, the id (0 or the integer) if the next
vdata is returned. On error, or when there are no more vdatas, -1 is
returned.
VSgetname
(void) VSgetname (vs, vsname)
VDATA *vs;
char *vsname;
Purpose: This inquiry routine returns in vsname the name (if
any) of the vdata vs.
Return value: None.
VSinquire
int VSinquire (vs, nelements, interlace,
fields, vsize, vsname)
VDATA *vs;
char *fields;
char *vsname;
int *vsize;
int *interlace;
int *nelements;
Purpose: VSinquire is the general vdata inquiry routine.
Specifics: Given a vdata vs, VSinquire returns the following
information about that vdata:
Ñ nelements the number of elements in vs
Ñ interlace the type of interlace: FULL_INTERLACE or
NO_INTERLACE
Ñ vsize the size in bytes of an element in vs
Ñ fields a comma-separated string listing all fields
in vs (e.g., "PX, PY, PZ")
Ñ vsname the name (if any) of vs
Return value: Upon success, 1 is returned; otherwise, -1.
VSlone
int VSlone (f, idarray, asize)
DF *f;
int idarray [ ];
int asize;
Purpose: This inquiry routine returns an array of reference
numbers of all vdatas that are not linked to any vgroup in the HDF
file.
Specifics: You must provide the integer array idarray, and you
must specify the integer size of the array in the argument asize.
The return value from this function will be the total number of
vdatas that are not linked to any vgroup in the file. But at most
asize reference numbers will be returned in idarray.
An array size of 65000 integers for idarray will be usually more
than adequate. To use dynamic memory instead, first call VSlone
with a small value (e.g., 0 or 1) for asize, and then use the
returned value to allocate memory for idarray to be passed to a
subsequent call to VSlone.
Return value: If there is an error, the return value is -1.
Otherwise, it returns the total number of all vdatas in the file that
are not linked to any vgroup.
VSread
int VSread (vs, databuf, nelements, interlace)
VDATA *vs;
int interlace;
int nelements;
unsigned char *databuf;
Purpose: VSread is the only read routine of the HDF Vset
interface.
Specifics: Given a vdata vs (with "r" access), and a buffer,
databuf, this routine returns the data read from that vdata in the
buffer.
You must specify in nelements the number of elements' worth of
data to be read, and the buffer interlace in interlace. (Specify
either NO_INTERLACE or FULL_INTERLACE).
If the call is successful, the data returned in databuf is laid out as
specified by interlace, and the data fields appear in the order
specified in the last call to VSsetfields for that vdata.
It is an error to read from a vdata without first calling
VSsetfields on that vdata.
Return value: The routine returns the number of elements read, if
successful; otherwise -1 is returned.
VSseek
int VSseek (vs,element)
VDATA *vs;
int element;
Purpose: This access routine moves the read pointer within the
vdata vs to the element specified by vertex. The next VSread
begins at this element position. For instance, specify element = 0
to seek to the first element; element = 1 to seek the second element,
etc.
Specifics: VSseek provides a mechanism for random-access
reads within a vdata. Each seek is constrained to an element
boundary within the vdata. The routine works for both fully- and
non-interlaced vdatas.
NOTE: This routine may only be used with a vdata attached with
"r" access.
Return value: The element position (i.e., zero or a positive
integer) is returned if the seek is successful. Otherwise, -1 is
returned.
VSsetclass
(void) VSsetclass (vs, vsclass)
VDATA *vs;
char *vsclass;
Purpose: This specify routine associates the class field name
vsclass with the vdata vs.
Specifics: Vdatas initially have a class name of NULL. The class
name may be reset more than once.
Return value: None.
VSsetfields
int VSsetfields (vs, fields)
VDATA *vs;
char *fields;
Purpose: This specify routine establishes the fields to be accessed
within the vdata vs by any subsequent read or write routine
(VSread or VSwrite). The fields are specified by the string
argument fields, a comma-separated list of fieldnames
(e.g. "PX,PY,PZ").
Specifics: The fieldnames allowed depends on the access of the
vdata:
Ñ If access is "r", the fieldnames must be one of the names of the
fields that already existed for that vdata.
Ñ If access is "w", the fieldnames can be one of the following:
(1) Pre-defined fieldnames (See Appendix C "Pre-defined
Fieldnames," for a list of pre-defined fieldnames.)
(2) Any fieldname that has been user-defined.
New or not pre-defined fieldnames should first be defined for a
vdata by calling the specify routine VSfdefine.
Return value: Upon success, 1 is returned; otherwise -1.
VSsetinterlace
int VSsetinterlace (vs, interlace)
VDATA *vs;
int interlace;
Purpose: This specify routine sets the interlace type as specified by
the argument interlace for the vdata vs.
Specifics: The interlace may be one of FULL_INTERLACE or
NO_INTERLACE. This routine applies only to new vdatas attached
with "w" access. The data is formatted and stored in that vdata
according to interlace.
Return value: Upon success, 1 is returned; otherwise -1.
VSsetname
(void) VSsetname (vs, vsname)
VDATA *vs;
char *vsname;
Purpose: This specify routine associates the name vsname with the
vdata vs.
Specifics: Vdatas initially have NULL names, and may be
renamed more than once. Note that the routine does NOT check for
uniqueness of vdata names.
Routine value: None.
VSwrite
int VSwrite (vs, databuf, nelements, interlace)
VDATA *vs;
int interlace;
int nelements;
unsigned char *databuf;
Purpose: This is the only write routine of the HDF Vset interface.
Specifics: Given a vdata vs (with "w" access), and a buffer,
databuf, containing data to be written, this routine will write the
data from the buffer out to the vdata.
You must specify in nelements, the number of elements╒ worth of
data to be written, and in interlace the buffer interlace. (Specify
either NO_INTERLACE or FULL_INTERLACE).
The data in databuf to be written is assumed to be laid out as
specified by interlace, and has the exact data fields (and order)
as specified in the last call to VSsetfields for that vdata.
It is an error to read from a vdata without first calling
VSsetfields on that vdata.
Note that interlace specifies how the data exists within the user's
buffer, databuf. If that data is to be stored in a vdata with an
interlace different from that of the buffer, VSsetinterlace must
be called prior to VSwrite.
Return value: The routine returns the number of elements read, if
successful; otherwise, -1 is returned.